package com.ql.gamelogm.service.impl;

import com.ql.gamelogm.dao.DataLogDao;
import com.ql.gamelogm.entities.*;
import com.ql.gamelogm.service.DataLogService;
import com.ql.gamelogm.utils.List2PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
@Service
public class DataLogServiceImpl implements DataLogService {
    @Autowired
    private List2PageUtil list2PageUtil;
    @Autowired
    private DataLogDao dataLogDao;
    @Autowired
    private JdbcTemplate jdbcTemplate;
    @Override
    public List<DataLog> findAllDataLogs() {
        return dataLogDao.findAllDataLogs();
    }

    @Override
    public List<ProblemData> findProblemLogs() {
        return dataLogDao.findProblemLogs();
    }

    @Override
    public Page<ProblemData> ProblemLogsList(int pageNum, int pageSize) throws ParseException {
        Pageable pageable= PageRequest.of(pageNum,pageSize);
        List<ProblemData> problemDataLogs=dataLogDao.findProblemLogs();
        return list2PageUtil.listConvertToPage(problemDataLogs,pageable);
    }
}
